package jp.seraph.robocup.soccer.research.ikinematics;

import javax.swing.JFrame;


import jp.seraph.jsade.math.Point3D;

@SuppressWarnings("")
public class IKRunner {

    /**
     * @param args
     */
    public static void main(String[] args) {
        LineModel tRoot = new LineModel(null, 10);
        LineModel tChild1 = new LineModel(tRoot, 10);
        LineModel tChild2 = new LineModel(tChild1, 10);
        LineModel tChild3 = new LineModel(tChild2, 10);
        LineModel tChild4 = new LineModel(tChild3, 10);
        JFrame tFrame = new JFrame("testCanvas");
        tFrame.add(new TestCanvas(tChild1, 500, 500));
        tFrame.setSize(550, 550);
        tFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        tFrame.setVisible(true);
        //test1();
        //test2();
    }

    private static void test1(){
        LineModel tRoot = new LineModel(null, 10);
        LineModel tChild = new LineModel(tRoot, 10);

        testSetPoint(tChild, new Point3D(10, 10, 0));
        testSetPoint(tChild, new Point3D(10, 0, 0));
        testSetPoint(tChild, new Point3D(20, 0, 0));
        testSetPoint(tChild, new Point3D(0, 20, 0));
        testSetPoint(tChild, new Point3D(0, 10, 0));
        testSetPoint(tChild, new Point3D(0, 30, 0));
        testSetPoint(tChild, new Point3D(14, 3, 0));
    }

    private static void test2(){
        LineModel tRoot = new LineModel(null, 10);
        LineModel tChild1 = new LineModel(tRoot, 10);
        LineModel tChild2 = new LineModel(tChild1, 10);

        testSetPoint(tChild2, new Point3D(10, 10, 0));
        testSetPoint(tChild2, new Point3D(10, 0, 0));
        testSetPoint(tChild2, new Point3D(20, 0, 0));
        testSetPoint(tChild2, new Point3D(0, 20, 0));
        testSetPoint(tChild2, new Point3D(0, 10, 0));
        testSetPoint(tChild2, new Point3D(0, 30, 0));
        testSetPoint(tChild2, new Point3D(14, 3, 0));
    }

    private static void testSetPoint(LineModel aModel, Point3D aTargetPoint){
        System.out.println("target -> " + aTargetPoint.toString());
        System.out.println(aModel.setEndPoint(aTargetPoint));
        System.out.println(aModel.getEndPoint().toString());
        System.out.println();
    }
}
